package network.course3.Threadpool;

public class Window implements Runnable{
    //锁
    private  static Object ob=new Object();
    private  String name;

    public Window(String name) {
        this.name = name;
    }

    @Override
    public void run() {
           while(Station.tick>0){
               try {
          synchronized (ob){
              if (Station.tick>0){
              System.out.println(name+"卖出了第"+Station.tick+"张车票");
              --Station.tick;}
              else {
                  System.out.println("票卖完了");
              }
          }

                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }

    }
}
